<template>
    <div>
        <el-collapse class="collapseList" v-model="activeNames" accordion style="margin-left: 5%">
            <el-collapse-item title="基本信息" name="1">
                <basics-form :item="form.basics_form"></basics-form>
            </el-collapse-item>
            <el-collapse-item title="申报信息" name="2">
                <basics-item :item="form.basics_item"></basics-item>
            </el-collapse-item>
            <el-collapse-item title="申报材料" name="3">
                <el-table
                        class="list"
                        :data="fileList"
                        @cell-click="downloadFile"
                        border
                        style="width: 100%">
                    <el-table-column
                            prop="name"
                            label="文件名">
                    </el-table-column>
                   <!-- <el-table-column
                            prop="updateDate"
                            width="105"
                            label="上传时间">
                    </el-table-column>-->
                </el-table>
            </el-collapse-item>

        </el-collapse>
        <el-dialog
                :title="fileTitle"
                :visible.sync="fileVisible"
                width="95%"
                center>
            <pdf-shower v-if="fileType" :url="fileUrl" style="width: 100%"></pdf-shower>
            <img v-if="!fileType" :src="fileUrl" style="width: 100%"/>
        </el-dialog>
        <!--<el-collapse-item title="临时表决" name="4" v-show="showTemporary">
                <el-form-item label="债权性质 ：">
                    <span>{{item.creditNature}}</span>
                </el-form-item>
                <el-form-item label="临时表决权金额 ：">
                    <span>{{item.temporaryTotal}}</span>
                </el-form-item>
                <el-form-item label="待定债权金额 ：">
                    <span>{{item.undecidedTotal}}</span>
                </el-form-item>
            </el-collapse-item>-->
        <div v-show="showAmend">
            <el-button type="primary" icon="el-icon-edit" plain round size="mini" style="margin:2% 5%" @click="toAmend">修改|补充基本信息</el-button>
        </div>
    </div>
</template>

<script>
    import BasicsForm from './basics_form'
    import BasicsItem from './basics_item'
    import util from 'assets/js/util.js'
    import conf from 'assets/js/conf.js'
    import PdfShower from 'components/pdf/pdf-shower.vue'

    export default {
        data() {
            return {
                //showTemporary:false,
                activeNames: [],
                fileList:[],
                fileVisible: false,
                fileUrl: '',
                total: 0,
                fileType: false,
                fileTitle: '',
            }
        },
        props: [
            'form',
            'showTemporary',
            'showAmend'
        ],
        mounted: function () {
            //this.id = util.getUrlParam(document.location.href, 'id');

            const _self = this;
            util.ajax({
                url: `/file/getFileList`,
                params: {eids: _self.form.declareFileids},
                success: function (data) {
                    data.data.forEach(_file => _self.fileList.push({
                        name: _file.name,
                        id: _file.id
                    }))
                },
            });
        },
        methods: {
            toAmend: function () {
                window.location.href = '../register/register-credit.html?'+ 'id=' + util.getUrlParam(document.location.href, 'id') + "&type=update" ;
            },
            downloadFile: function (row, column, cell, event) {
                 window.open(conf.baseUrl + '/file/get/' + row.id + '?type=1')
                // this.fileUrl = conf.baseUrl + '/file/get/'  + row.id + '?type=1';
                // this.fileTitle = row.name;
                // this.fileType = row.type;
                // this.fileVisible = true;
            },
        },
        components: {
            BasicsForm,
            BasicsItem,
            PdfShower
        },
    }
</script>

<style scoped>
    .list {
        margin: 20px auto;
    }

</style>
